<template>
	<view class="wrap">
		<page-nav :desc="desc" title="nav.template"></page-nav>
		<view class="list-wrap">
			<u-cell-group title-bg-color="rgb(243, 244, 246)" :title="getGroupTitle(item)" v-for="(item, index) in list"
				:key="index">
				<u-cell-item :titleStyle="{fontWeight: 500}" @click="openPage(item1.path)" :title="getFieldTitle(item1)"
					v-for="(item1, index1) in item.list" :key="index1">
					<image slot="icon" class="u-cell-icon" :src="getIcon(item1.icon)" mode="widthFix"></image>
				</u-cell-item>
			</u-cell-group>
		</view>
		<u-gap height="70"></u-gap>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						groupName: '部件',
						groupName_en: 'Parts',
						list: [{
							path: 'coupon',
							icon: 'coupon',
							title: 'Coupon 优惠券',
							title_en: 'Coupon',
						}]
					},
					{
						groupName: '页面',
						groupName_en: 'Page',
						list: [{
								path: '/pages/template/wxCenter/index',
								icon: 'wxCenter',
								title: 'WxCenter 仿微信个人中心',
								title_en: 'WxCenter',
							},
							{
								path: '/pages/template/keyboardPay/index',
								icon: 'keyboardPay',
								title: 'KeyboardPay 自定义键盘支付模板',
								title_en: 'KeyboardPay',
							},
							{
								path: '/pages/template/mallMenu/index1',
								icon: 'mall_menu_1',
								title: 'MallMenu 垂直分类(左右独立)',
								title_en: 'MallMenu 1',
							}, {
								path: '/pages/template/mallMenu/index2',
								icon: 'mall_menu_2',
								title: 'MallMenu 垂直分类(左右联动)',
								title_en: 'MallMenu 2',
							}, {
								path: 'submitBar',
								icon: 'submitBar',
								title: 'SubmitBar 提交订单栏',
								title_en: 'SubmitBar',
							}, {
								path: 'comment',
								icon: 'comment',
								title: 'Comment 评论列表',
								title_en: 'Comment',
							}, {
								path: 'order',
								icon: 'order',
								title: 'Order 订单列表',
								title_en: 'Order',
							}, {
								path: 'login',
								icon: 'login',
								title: 'Login 登录界面',
								title_en: 'Login',
							}, {
								path: 'address',
								icon: 'address',
								title: 'Address 收货地址',
								title_en: 'Address',
							}, {
								path: 'citySelect',
								icon: 'citySelect',
								title: 'CitySelect 城市选择',
								title_en: 'CitySelect',
							}
						]
					}
				],
			}
		},
		computed: {
			getIcon() {
				return path => {
					return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
				}
			},
			desc() {
				return this.$t('template.desc');
			}
		},
		onShow() {
			uni.setNavigationBarTitle({
				title:this.$t('nav.template')
			});
		},
		methods: {
			openPage(path) {
				this.$u.route({
					url: path.indexOf('/page') == 0 ? path : '/pages/template/' + path + '/index'
				})
			},
			getGroupTitle(item) {
				return this.$i18n.locale == 'zh' ? item.groupName : item.groupName_en
			},
			getFieldTitle(item) {
				return this.$i18n.locale == 'zh' ? item.title : item.title_en
			}
		}
	}
</script>

<style lang="scss" scoped>
	.u-cell-icon {
		width: 36rpx;
		height: 36rpx;
		margin-right: 8rpx;
	}
</style>
